namespace PowerManage.Entity;

/**
 * 响应结果类
 */
public class ResponseResultDto {
    public ResponseResultDto() {
        Code = ResponseCode.Success;
        Message = "操作成功";
    }

    /**
     * 状态码
     */
    public ResponseCode Code { get; set; }

    /**
     * 提示信息
     */
    public string Message { get; set; }

    /**
     * 设置成功状态
     * string message = "成功"这样写是为了： 如果调用方法时不传入参数，将使用默认值 "成功"
     * return this： 返回this可以进行链式调用
     */
    public ResponseResultDto SetSuccess(string message = "成功") {
        Code = ResponseCode.Success;
        Message = message;
        return this; // 返回当前对象实例
    }

    /**
     * 设置失败状态
     */
    public ResponseResultDto SetError(string message = "失败") {
        Code = ResponseCode.Error;
        Message = message;
        return this;
    }

    /**
     * 设置未认证状态
     */
    public ResponseResultDto SetUnauthorized(string message = "未认证") {
        Code = ResponseCode.Unauthorized;
        Message = "未认证";
        return this;
    }

    /**
     * 设置未授权状态
     */
    public ResponseResultDto SetNoPermission(string message = "未授权") {
        Code = ResponseCode.NoPermission;
        Message = message;
        return this;
    }

    /**
     * 设置未找到状态
     */
    public ResponseResultDto SetNotFound(string message = "未找到") {
        Code = ResponseCode.NotFound;
        Message = message;
        return this;
    }
}